<?php
$host="db.seng.uvic.ca"; // Host name
$username="se321g01"; // Mysql username
$password="un8bi2YM"; // Mysql password
$db_name="se321g01"; // Database name
$tbl_name="user_info"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Personal
$firstname=$_POST['txtFirstName'];
$lastname=$_POST['txtLastName'];
$email=$_POST['txtEmail'];
$password=$_POST['Password'];

// Shipping
$scountry=$_POST['country'];
$sprovince=$_POST['province'];
$scity=$_POST['city'];
$saddress=$_POST['streetAddress'];
$spostal=$_POST['postalCode'];
$sphone=$_POST['phone'];

//Billing
$bcountry=$_POST['country2'];
$bprovince=$_POST['province2'];
$bcity=$_POST['city2'];
$baddress=$_POST['streetAddress2'];
$bpostal=$_POST['postalCode2'];
$bphone=$_POST['phone2'];
$bmethod=$_POST['credit'];
$bnumber=$_POST['cardnum'];
$bmonth=$_POST['cardmonth'];
$byear=$_POST['cardyear'];

// Get UID
$uid = $_GET['uid'];

// Update into user_info
mysql_query("UPDATE user_info
SET first_name='$firstname', last_name='$lastname', email='$email', passwd='$password'
WHERE uid='$uid'");

// Update into shipping_info
mysql_query("UPDATE shipping_info
SET country='$scountry', province='$sprovince', city='$scity', street_address='$saddress', postal_code='$spostal', phone='$sphone'
WHERE uid='$uid'");

// Update into billing_info
mysql_query("UPDATE billing_info
SET country='$bcountry', province='$bprovince', city='$bcity', street_address='$baddress', postal_code='$bpostal', phone='$bphone',
payment_method='$bmethod', card_number='$bnumber', expiry_date_year='$byear', expiry_date_month='$bmonth'
WHERE uid='$uid'");

// Go back to profile
header("location:./profile.php?uid=" . $uid . "&tab=6");

?>
